package com.xy.biz.ts.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.ts.domain.bo.LearnRecordBO;
import com.xy.biz.ts.domain.po.LearnRecordPO;
import com.xy.biz.ts.domain.query.LearnRecordQuery;
import com.xy.biz.ts.domain.resp.GetLearnRecordResponse;
import com.xy.biz.ts.domain.req.SaveLearnRecordRequest;
import com.xy.biz.ts.domain.req.ListLearnRecordRequest;
import com.xy.tool.util.BeanUtilsEx;

/**
 *
 *
 * @author yzh
 * @date 2021-3-29
 */
public class LearnRecordConverter {

	public static LearnRecordPO toPO(LearnRecordBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new LearnRecordPO(), true);
	}

	public static List<LearnRecordPO> toPO(Collection<LearnRecordBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new LearnRecordPO(), true);
	}

	public static LearnRecordBO fromPO(LearnRecordPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new LearnRecordBO());
	}

	public static List<LearnRecordBO> fromPO(Collection<LearnRecordPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new LearnRecordBO());
	}

	public static LearnRecordBO toBO(SaveLearnRecordRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new LearnRecordBO(), true);
	}

	public static List<LearnRecordBO> toBO(Collection<SaveLearnRecordRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new LearnRecordBO(), true);
	}

	public static GetLearnRecordResponse toResponse(LearnRecordBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetLearnRecordResponse());
	}

	public static List<GetLearnRecordResponse> toResponse(Collection<LearnRecordBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetLearnRecordResponse());
	}

	public static LearnRecordQuery toQuery(ListLearnRecordRequest source) {
		if(null == source) {
			return null;
		}
		LearnRecordQuery target = new LearnRecordQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
